//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>
package org.jpgolay.wi.user;

import java.awt.*;
import java.util.ResourceBundle;
import javax.swing.*;

public class ConnectionGUI extends JFrame {

    public ConnectionGUI() {
        initComponents();
        setIconImage((new ImageIcon(getClass().getResource("/org/jpgolay/wi/images/logo.gif"))).getImage());
    }

    private void initComponents() {
        identifiantsP = new JPanel();
        utilisateurL = new JLabel();
        utilisateurF = new JTextField();
        passwordL = new JLabel();
        passwordPF = new JPasswordField();
        bouttonsP = new JPanel();
        validerB = new JButton();
        annulerB = new JButton();
        setTitle(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("welcome_title"));
        setResizable(false);
        identifiantsP.setLayout(new GridLayout(2, 2));
        utilisateurL.setHorizontalAlignment(0);
        utilisateurL.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("Username"));
        identifiantsP.add(utilisateurL);
        identifiantsP.add(utilisateurF);
        passwordL.setHorizontalAlignment(0);
        passwordL.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("Password"));
        identifiantsP.add(passwordL);
        identifiantsP.add(passwordPF);
        getContentPane().add(identifiantsP, "Center");
        bouttonsP.setLayout(new FlowLayout(1, 20, 5));
        validerB.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("ok"));
        bouttonsP.add(validerB);
        annulerB.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("cancel"));
        bouttonsP.add(annulerB);
        getContentPane().add(bouttonsP, "South");
        pack();
    }

    public JButton getValiderB() {
        return validerB;
    }

    public JButton getAnnulerB() {
        return annulerB;
    }

    public JPasswordField getPasswordPF() {
        return passwordPF;
    }

    public char[] getPassword() {
        return passwordPF.getPassword();
    }

    public String getUtilisateur() {
        return utilisateurF.getText();
    }

    public void initFields() {
        utilisateurF.setText("");
        passwordPF.setText("0000000000");
    }

    public void setTitleFrame(String titleFrame) {
        setTitle(titleFrame);
    }
    private JButton annulerB;
    private JPanel bouttonsP;
    private JPanel identifiantsP;
    private JLabel passwordL;
    private JPasswordField passwordPF;
    private JTextField utilisateurF;
    private JLabel utilisateurL;
    private JButton validerB;
}
